<script>
import { initUser } from './utils/auth.js'

export default {
	onLaunch: function() {
		console.log('App Launch')
		
		// 初始化用户信息
		const userInfo = initUser()
		console.log('用户信息已初始化:', userInfo)
		
		// 初始化权限系统
		this.initPermissionSystem()
	},
	onShow: function() {
		console.log('App Show')
	},
	onHide: function() {
		console.log('App Hide')
	},
	methods: {
		initPermissionSystem() {
			try {
				// 检查用户登录状态
				const userInfo = uni.getStorageSync('userInfo')
				if (!userInfo) {
					console.log('用户未登录，使用默认角色')
				} else {
					console.log('用户已登录:', userInfo)
				}
			} catch (error) {
				console.error('初始化权限系统失败:', error)
			}
		}
	}
}
</script>

<style>
	/*每个页面公共css */
	@import "./common/app.css";
	/*每个页面公共css */
	page {
		background-color: #f8fafc;
		font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	}

	/* 图标字体 */
	@font-face {
		font-family: 'iconfont';
		src: url('data:font/woff2;charset=utf-8;base64,d09GMgABAAAAAA...') format('woff2');
	}

	.iconfont {
		font-family: 'iconfont' !important;
		font-style: normal;
		font-weight: normal;
		font-variant: normal;
		text-transform: none;
		line-height: 1;
		-webkit-font-smoothing: antialiased;
		-moz-osx-font-smoothing: grayscale;
	}

	/* 通用样式 */
	.container {
		padding: 16px;
	}

	.card {
		background: white;
		border-radius: 12px;
		padding: 16px;
		margin-bottom: 16px;
		box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
	}

	.btn {
		padding: 12px 24px;
		border-radius: 8px;
		font-size: 14px;
		font-weight: 500;
		border: none;
		cursor: pointer;
		transition: all 0.2s;
	}

	.btn-primary {
		background: #3b82f6;
		color: white;
	}

	.btn-primary:hover {
		background: #2563eb;
	}

	.btn-secondary {
		background: #f3f4f6;
		color: #6b7280;
	}

	.btn-secondary:hover {
		background: #e5e7eb;
	}

	.text-primary {
		color: #3b82f6;
	}

	.text-success {
		color: #10b981;
	}

	.text-warning {
		color: #f59e0b;
	}

	.text-error {
		color: #ef4444;
	}

	.text-gray {
		color: #6b7280;
	}

	/* 状态样式 */
	.status-badge {
		padding: 4px 8px;
		border-radius: 12px;
		font-size: 12px;
		font-weight: 500;
	}

	.status-purchasing {
		background: #dbeafe;
		color: #3b82f6;
	}

	.status-inspecting {
		background: #fef3c7;
		color: #f59e0b;
	}

	.status-transferring {
		background: #dcfce7;
		color: #10b981;
	}

	.status-exporting {
		background: #f3e8ff;
		color: #8b5cf6;
	}

	.status-shipping {
		background: #fed7aa;
		color: #f97316;
	}

	/* 响应式设计 */
	@media (max-width: 768px) {
		.container {
			padding: 12px;
		}
		
		.card {
			padding: 12px;
			margin-bottom: 12px;
		}
		
		.btn {
			padding: 10px 20px;
			font-size: 13px;
		}
	}
</style>
